package com.estate.struts.actions;

import com.estate.business.ManageProjectService;
import com.estate.vo.impl.ManageProjectVo;

public class MultiOperationInManageProAction extends EstateSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ManageProjectService manageProjectService;
	private String operationType;
	private String deleStr;
	private String stepStr;
	private String statStr;
	private String currentPage;
	
	

	public String execute() throws Exception {
		
		if(operationType.equals("multidel")){
			System.out.println("!!!!!!!!!"+deleStr);
			if (deleStr != null && !"".equals(deleStr) && !",".equals(deleStr)) {
				String[] deleArray = deleStr.split(",");
				for (int i = 0; i < deleArray.length; i++){
					manageProjectService.deleteManageProjectVoByPK((Integer.parseInt(deleArray[i])));
				}
			}
			
		}else if(operationType.equals("multipush")){
			System.out.println("multipush=======================multipush");
			if (stepStr != null && !"".equals(stepStr) && !",".equals(stepStr)) {
				String[] stepArray = stepStr.split(",");
				for (int i = 0; i < stepArray.length; i++){
					ManageProjectVo vo = (ManageProjectVo) manageProjectService.getManageProjectByPK(Integer.parseInt(stepArray[i]));
					int vo_CurrentStep = vo.getCurrentStep();
					if(vo_CurrentStep<2){
						vo.setCurrentStep(vo_CurrentStep+1);
						manageProjectService.updateManageProjectVo(vo);
					}
				}
			}
			
			
		}else if(operationType.equals("multiback")){
			if (stepStr != null && !"".equals(stepStr) && !",".equals(stepStr)) {
			
				String[] stepArray = stepStr.split(",");
			
				for (int i = 0; i < stepArray.length; i++){
				
					ManageProjectVo vo = (ManageProjectVo) manageProjectService.getManageProjectByPK(Integer.parseInt(stepArray[i]));
				    int vo_CurrentStep = vo.getCurrentStep();
				    if(vo_CurrentStep>0){
					     vo.setCurrentStep(vo_CurrentStep-1);
					     manageProjectService.updateManageProjectVo(vo);
					     }
				    }
				}
			
		}else if(operationType.equals("multiannounce")){
			if (statStr != null && !"".equals(statStr) && !",".equals(statStr)) {
				
				String[] statArray = statStr.split(",");
			
				for (int i = 0; i < statArray.length; i++){
				
					ManageProjectVo vo = (ManageProjectVo) manageProjectService.getManageProjectByPK(Integer.parseInt(statArray[i]));
			        vo.setState(1);
					manageProjectService.updateManageProjectVo(vo);
					     
				    }
				}
			
			
			
		}
		return this.getCurrentPage();
	}

	

	


	public ManageProjectService getManageProjectService() {
		return manageProjectService;
	}
	
	public void setManageProjectService(ManageProjectService manageProjectService) {
		this.manageProjectService = manageProjectService;
	}

	public String getOperationType() {
		return operationType;
	}
	
	public void setOperationType(String operationType) {
		this.operationType = operationType;
	}

	public String getDeleStr() {
		return deleStr;
	}
	
	public void setDeleStr(String deleStr) {
		this.deleStr = deleStr;
	}
	
	public String getStepStr() {
		return stepStr;
	}

	public void setStepStr(String stepStr) {
		this.stepStr = stepStr;
	}

	public String getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(String currentPage) {
		this.currentPage = currentPage;
	}


	public String getStatStr() {
		return statStr;
	}

	public void setStatStr(String statStr) {
		this.statStr = statStr;
	}






	

	

	


}
